#!/bin/bash

# 确保在 /root 目录下运行
cd /root

# 1. 安装必要的工具
echo "安装 git, wget..."
apt-get update && apt-get install -y git wget

# 2. 下载并安装 Oh My Zsh
echo "下载并安装 Oh My Zsh..."
sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)" "" --unattended || {
    echo "Oh My Zsh 安装失败！"
    exit 1
}

# 3. 安装 zsh-syntax-highlighting 插件
echo "安装 zsh-syntax-highlighting 插件..."
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-/root/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

# 4. 安装 zsh-autosuggestions 插件
echo "安装 zsh-autosuggestions 插件..."
git clone https://github.com/zsh-users/zsh-autosuggestions.git ${ZSH_CUSTOM:-/root/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

# 5. 配置 .zshrc 文件
echo "配置 .zshrc 文件..."
sed -i 's/plugins=(git)/plugins=(git z zsh-syntax-highlighting zsh-autosuggestions)/g' /root/.zshrc

# 6. 设置 Zsh 为默认 Shell
echo "设置 Zsh 为默认 Shell..."
chsh -s $(which zsh)

echo "Zsh 配置完成！请重新启动 Shell 以使配置生效。"
